<link href="/media/css/form.css" rel="stylesheet" type="text/css" />
<link href="/media/css/Title_white.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
</script>


{% extends 'base.html' %}
{% block title %} - Project {{project.name}} edit mode{% endblock %}
{% block js %}
<script type="text/javascript" src="/site_media/js/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="/site_media/js/flowplayer-3.0.3.min.js"></script>
<link rel="stylesheet" href="/site_media/css/jquery.wysiwyg.css" type="text/css" />
<script type="text/javascript">
	$(function()
	{
		$('#wysiwyg').wysiwyg();
	});
	
	
	
	function play_video(video){ // 2011-02-06 By daoyu
		$('#playVideo').html("<div id='player'></div>");
		$('#playVideo').dialog("destroy");
		$('#playVideo').dialog( {
			title : 'Play Video',
			zIndex : 900,
			width : 700,
			height : 500,
			draggable : false,
			resizable : false,
			bgiframe : true,
			autoOpen : true,
			modal : true,
			buttons : {
				Close : function() {
					$(this).dialog("close");
					$("#player").html("");
				}
			}
		});
		
		var player = flowplayer("player", "/site_media/flowplayer-3.2.2.swf", {
			clip: {
				url: '/{{pv}}',
				provider: 'h264streaming',
				autoPlay:true,
				autoBuffering:true,
				scaling: "scale"
			},
			plugins: {
				h264streaming: {
					url: '/site_media/flowplayer.pseudostreaming-3.2.2.swf'
				},
				controls: {
					url: '/site_media/flowplayer.controls-3.2.1.swf',
					play:true,
					stop:true,
					scrubber: true
				}
			}
		});	
	}
	
	function check_youtube(youtube_form){
		if (youtube_form.new_youtube.value==""){
			alert("Please input the youtube URL!");
			return false;
		}
		return true;
	}
	
	function check_file(file_form){
		if (file_form.new_file.value==""){
			alert("Please select a file to upload!");
			return false;
		}
		return true;
	}
	
	
	function show_youtube(youtube_show_form){
		if (youtube_show_form.show_youtube.value){
	
			return true;
		}
		show_youtube = false
		return true;
	}
	
	
	function check_email(email_form){
		if ( email_form.client_email.value == ""){
			alert("Please input the client's email!");
			return false;
		}
		
		return true;
	}
	
	
	
	

	var player = flowplayer("player", "/site_media/flowplayer-3.2.2.swf", {
		clip: {
			url: '/{{pv}}',
			provider: 'h264streaming',
			autoPlay:false,
			autoBuffering:true,
			scaling: "scale"
		},
		plugins: {
			h264streaming: {
				url: '/site_media/flowplayer.pseudostreaming-3.2.2.swf'
			},
			controls: {
				playlist: true,
				url: '/site_media/flowplayer.controls-3.2.1.swf',
				play:true,
				stop:true,
				fullscreen:true,
				scrubber: true
			}
		}
	});	
	
	function play_project_file(video_path, video_title, video_text){
		$("#player").html('').css('display','');
		$("#youtube").html('');
		flowplayer("player", "/site_media/flowplayer-3.2.2.swf", {
			clip: {
				url: '/' + video_path,
				provider: 'h264streaming',
				autoPlay:false,
				autoBuffering:true,
				scaling: "scale"
			},
			plugins: {
				h264streaming: {
					url: '/site_media/flowplayer.pseudostreaming-3.2.2.swf'
				},
				controls: {
					playlist: true,
					url: '/site_media/flowplayer.controls-3.2.1.swf',
					play:true,
					stop:true,
					fullscreen:true,
					scrubber: true
				}
			}
		});	
		
		$("#video_title").html(video_title);
		$("#video_description").html(video_text);
	}

	function play_youtube(youtube){
		$("#player").html('').css('display','none');
		i_html = '<object width="600" height="330"> ' +
			'<param name="movie" value="http://www.youtube.com/v/'+
			youtube +'&amp;hl=zh_CN&amp;fs=1"></param>' +
			'<param name="allowFullScreen" value="true"></param>' +
			'<param name="allowscriptaccess" value="always"></param>' +
			'<embed src="http://www.youtube.com/v/' + youtube +
			'&amp;hl=zh_CN&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="330"></embed></object>';

		document.getElementById('youtube').innerHTML =  i_html;
	}
	
</script>
<script type="text/javascript" src="/site_media/js/flowplayer-3.0.3.min.js"></script>
{% endblock %}
{% block content %}

<div id="content" style="position:absolute; top:20px; left:0px; width:1000px; height:relative; background-color: #1A1A1A; layer-background-color: #1A1A1A; border: 1px none #000000; z-index:1">

<table>
<tr><td colspan="2">

  <table width="100%" border="0" cellspacing="10">
    <tr><td class="Headline_player">Thanks for letting us pitch on this great Job. <button onclick="window.location.href ='/project/{{project.id}}/'" >View</button></td></tr>
  </table>
  <table width="980" height="8" cellpadding="0" cellspacing="0">
    <tr class="text">
      <td width="76" bgcolor="#b3995d"></td>
      <td width="922" bgcolor="#323232"></td>
    </tr>
  </table>
  </td></tr>
 
 <tr><td>
  <table border="0" align="left" cellpadding="0" cellspacing="10">
<form action="/project/{{project.id}}/change_name/" method="post">
    <tr>
      <th class="Headline_white">Project:</th>
      <td><span class="Title_Proj_name"><input name="project_name" type="text" value="{{project.name}}"/></span></th>

    </tr>
    <tr>
      <th class="Headline_white">Brand:</th>
      <td class="Title_Proj_info2" colspan="3"><input name="project_brand" type="text" value="{{project.brand}}"/></td>
    </tr>
    <tr>
      <th class="Headline_white">For You:</th>
      <td class="Title_Proj_info2" colspan="3"><input name="project_city" type="text" value="{{project.city}}"/></td>
    </tr>
    <tr>
      <td class="Headline_white_small">Producer:</td>
      <td class="Title_project_info_small" colspan="3">
		<span class="text">
			{{project.creator.first_name}}, {{project.creator.last_name}}
            <a href="mailto:{{project.creator.email}}">{{project.creator.email}}</a>
		</span></td>
    </tr>
    <tr>
      <td class="Headline_white_small">Supervision:</td>
      <td class="Title_project_info_small" colspan="3"><span class="text">{{project.creator.first_name}}, {{project.creator.last_name}} ({{project.creator.username}})</span><br/></td>
      <td align="right" valign="bottom"><br/><input type="submit" value="Change"/></td>
    </tr>
</form>
  </table>
</td>

<td>

<table>
      <tr><td colspan="4">E-mail clients:</td></tr>
      <tr><td colspan="4">                        
    {% for pce in pces %}
       {{pce.title}} {{pce.name}} (<a href="mailto:{{pce.email}}">{{pce.email}}</a>) 
        <a href="/project/{{project.id}}/client_email/{{pce.id}}/" onclick="return confirm('Delete this client email?');">
            <img src="/site_media/img/trash.gif">
        </a>
        <br>
    {% endfor %}
    </td></tr>
    
      <form action="/project/{{project.id}}/add_client_email/" method="post" onsubmit="return check_email(this);">

     <tr><td>Name:<br /><input name="client_name" type="text" size="20" /> </td>
     <td>Title:<br /><input name="client_title" type="text" size="15" /></td></tr>
     <tr><td>E-mail:<br /><input name="client_email" type="text" size="20" /></td>
     <td align="right"><br><input type="submit" value="Add" /></td></tr>
     </form>
     
</table>





</td></tr>



<tr><td>

  <table width="562" border="0" cellspacing="10">
     <form method="post" action="/project/{{project.id}}/save/">
    <tr>
      <td class="text"><p>Description:</p>
      <textarea name="description" {% if user.is_authenticated %}id="wysiwyg"{% endif %} rows="10" cols="82">{{project.description}}</textarea>
      <input type="submit" value="Change">
      </td>
    </tr>
    </form>
  </table>
</td>

<td>

  <table width="100%" border="0" align="center" cellspacing="10" class="text">    
	<tr>
	  <td colspan="2">Attachments:   <input type="submit" onclick="MM_showHideLayers('import_attachment','','show')" value="Import attachment"></td></tr> 	 
    
    {% for pfs in pfss %}
    {% for pf in pfs %}
	{% if pf.show %}    
	
    <tr>
    	<td class="Headline_white_small">
			{{pf.title}}
		</td>
		<td>&gt;
			<a href="?m={{pf.id}}" onClick="play_youtube('{{p.youtube}}');MM_setTextOfLayer('video_title','','{{ pf.title }}');MM_setTextOfLayer('video_description','','{{ pf.text }}')">Show Attachment</a><br/>
		</td>
	</tr>
	{% endif %}
    {% endfor %}
    {% endfor %}
  </table>

</td></tr>



<tr><td>
	<div id="youtube"></div>
	<div id="player" style="display:block;width:600;height:330px;"></div>	
</td>



<td>
  <table width="350" border="0" cellspacing="10">
    <tr>
      <td width="363" class="Headline_player" id="video_title">Title:<br/><input name="video_title" type="text" value="{{ p.youtube_title }}"/></td>
    </tr>
    <tr>
      <td class="Headline_player" id="video_artist"></td>
    </tr>
    <tr>
      <td class="text" id="video_description">Comment<br/><textarea name="video_title" width="60" rows="4"type="text" value="{{ p.youtube_text }}"/></textarea></td>
    </tr>
  </table>
</td></tr>



<tr><td colspan="2">
  <table width="100%" border="0" cellspacing="10">
    <tr><th class="Headline_white" colspan="6"><br/>Project basket: {{project.name}}
    <input type="submit" onclick="MM_showHideLayers('import_file','','show')" value="Import video">
  
    {% if perms.users.is_producer or perms.users.is_kth%}
	<script>
		function check_basket(bas_form){
			if (bas_form.basket.value==""){
				alert("Please chose a basket !");
				return false;
			}
			
			#new Ajax.Request("/user/basket/add/", {asynchronous:true, parameters:Form.serialize(bas_form)});
			import_video_from_basket(bas_form.basket.value);
			alert("Successful import from your basket!");
			return false;
		}
		
		function import_video_from_basket(aid){
		$('#playVideo').html('');
		#var url = "/project/{{project.id}}/artist/video/" + aid + "/";
		$.get(url, function(data) {
			$('#playVideo').html(data);
		});
				
		
		$('#playVideo').dialog("destroy");
		$('#playVideo').dialog( {
			title : 'Import videos from basket',
			zIndex : 900,
			width : 800,
			height : 500,
			draggable : false,
			resizable : false,
			bgiframe : true,
			autoOpen : true,
			modal : true,
			buttons : {
				Close : function() {
					$(this).dialog("close");
					$("#player").html("");
				}
			}
		});
	}
	</script>
	
	<form action="" method="post" onsubmit="return check_basket(this);">
		<select name="basket">
			<option value="">-------</option>
			{% for ba in bas %}
				<option value="{{ba.id}}">{{ba.name}}</option>
				<a href="javascript:;" title="View artist profile" onclick="import_video_from_basket({{ba.id}});">
			{% endfor %}
		</select>
		<input name="p_id" type="hidden" value="{{project.id}}"/>
		<input type="submit" value="import from basket"/> <br/>
		
		<a href="/user/basket/">Manage your baskets</a>
	</form>
	{% endif %}
    
    
    </tr>
    
    
    <tr><th class="Headline_white" colspan="6"><br/>Artist videos:</th></tr>
    <table width="610">
		{% for pas in pass %}
	    <tr>
			{% for pa in pas %}
			<td width="100" align="center">
				{% if user.username == 'kth' %}
					<a onclick="return confirm('Delete this artist?');"
						href="/project/{{project.id}}/artist/{{pa.id}}/" title="Delete">
						<img src="/site_media/img/trash.gif">
			  		</a>
					{% else %}
					{% if user.id == project.creator.id %}
						<a onclick="return confirm('Delete this artist?');"
						href="/project/{{project.id}}/artist/{{pa.id}}/">
						<img src="/site_media/img/trash.gif">
					</a>
					{% endif %}
					{% endif %}
	                <br />
			
				{% if pa.video == '' %}
				
					<a href="?a={{pa.artist.get_profile.film}}/" title="{{ pa.artist.get_profile.client_text}} ">
						{% load zdy_filter %}
						<img src="/{{pa.artist.get_profile.film|get_file_name}}.jpg" height="50">
					</a>			
	
				{% else %}
					<a href="?a={{pa.video}}" title="{{ pa.artist.get_profile.client_text }}">
						{% load zdy_filter %}
						<img src="/{{pa.video|get_file_name}}.jpg" border="5" height="80">
					</a>
				{% endif %}
			   <br/>
	              {{pa.artist.first_name}} {{pa.artist.last_name}}</a><br/>
	              {{pa.artist.get_profile.role}}
			</td>
	        	
	
		   {% endfor %}
	    </tr>
		{% endfor %}
	    <a href="/video/{{movie.id}}/">    
	     </a>

  </table>
  
  
  
  
  
</td></td>




<tr><td colspan="2">


  <table width="610">
	<tr>
    <th class="Headline_white" colspan="6"><br/>Moods/References:</th>
    </tr>
	   {% for py in pys%}
	   <tr>
	     {% for p in py %}
	     <td width="100" align="center">
	       
	       <a href="/project/{{project.id}}/youtube/{{p.id}}/" onclick="return confirm('Delete this youtube URL?');">
           <img src="/site_media/img/trash.gif"></a>
	       
    	{% if p.show %}
		<a href='/project/{{project.id}}/youtube/hide/{{p.id}}/'>Hide</a>
     	{% else %}
		<a href='/project/{{project.id}}/youtube/show/{{p.id}}/'>Show</a>
      	{% endif %}     	
	    
           <br/>
	       
	       <a href="javascript:;" onClick="play_youtube('{{p.youtube}}');MM_setTextOfLayer('video_title','','{{ p.youtube_title }}');MM_setTextOfLayer('video_description','','{{ p.youtube_text }}')" >
	         <img src="http://img.youtube.com/vi/{{p.youtube}}/0.jpg" height="50"/>
           </a><br />
	       
	       {% if p.youtube_title != "" %}
	       {{ p.youtube_title }}
	       {% endif %}
	       	       
         </td>
	     {% endfor %}
       </tr>
	   {% endfor %}  

</table>
  
  
  
  
</td></tr>


<tr><td colspan="2">

  
  <table width="610">         
	{% for pfs in pfss %}
	<tr>
		{% for pf in pfs %}
		<td width="100" align="center" >      
	
			
			{% if user.username == 'kth' %}
			<a onclick="return confirm('Delete this file?');" href="/project/{{project.id}}/file/{{pf.id}}/"><img src="/site_media/img/trash.gif"></a>
			{% else %}
			{% if user.id == project.creator.id %}
			<a onclick="return confirm('Delete this file?');" href="/project/{{project.id}}/file/{{pf.id}}/"><img src="/site_media/img/trash.gif"></a>
			{% endif %}{% endif %}
            
            
            
           <input name="file_show" type="hidden" value=""/>
			{% if pf.show %}
			<a href="/project/{{project.id}}/file/hide/{{pf.id}}/">Hide</a>
			{% else %}
			<a href="/project/{{project.id}}/file/show/{{pf.id}}/">Show</a>
			{% endif %}
			<br/>
            
            <a href="javascript:;" onMouseDown="play_video('/{{pf.file}}');">
			{% load zdy_filter %} 
			<img height="50" src="/{{pf.file.name|get_project_file_img}}"><br>{{pf.title}}
			</a> 
			
		</td>
		{% endfor %}
	</tr>
	{% endfor %}
</table>
  
  
  
  
  
</td></td>
<tr><td align="left"><FORM><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"> </FORM></td></td

></table>


</div>
    
    

   <div id="import_file" style="position:absolute; left:20px; top:913px; visibility:hidden; background-color: #1A1A1A; layer-background-color: #1A1A1A; border: 1px none #000000; z-index:2" >
<table width="610">
<form enctype="multipart/form-data" action="/project/{{project.id}}/addfile/" method="post" onsubmit="return check_file(this);MM_showHideLayers('import_file','','hide')">


<tr><td colspan="2">New file: <br><input name="new_file" type="file" title="Add new file" size="15" />	<br/>
    
    Title:<br><input name="title" type="title" size="20"/></td>
    
  <td colspan="3">Description:<br><textarea name="txt" cols="40" rows="3" /></textarea></td>
  <td><input name="file_show" type="hidden" value=""/>  
    Show:<br><input name="file_show" type="checkbox"/><br/><br/>
    <input type="submit" value="Upload"/><a onclick="MM_showHideLayers('import_file','','hide')">Canacel</a>
    </td>
  </tr>
</form>
</table>
</div>  

<div id="import_attachment" style="position:absolute; left:660px; top:300px; visibility:hidden; background-color: #1A1A1A; layer-background-color: #1A1A1A; border: 1px none #000000; z-index:2" >
<table width="610">
<form enctype="multipart/form-data" action="/project/{{project.id}}/addfile/" method="post" onsubmit="return check_file(this);MM_showHideLayers('import_attachment','','hide')">


<tr><td colspan="2">New Attachment: <br><input name="new_file" type="file" title="Add new file" size="15" />	<br/>
    Title:<br><input name="title" type="title" size="20"/></td>
    
  <td colspan="3">Description:<br><textarea name="txt" cols="40" rows="3" /></textarea></td>
  <td><input name="file_show" type="hidden" value=""/>  
    Show:<br><input name="file_show" type="checkbox"/><br/><br/>
    <input type="submit" value="Upload"/><a onclick="MM_showHideLayers('import_attachment','','hide')">Canacel</a>
    </td>
  </tr>
</form>
</table>
</div> 


    
    
{% endblock %}